using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace Persistent
{
    public class PersistentContext : DbContext
    {
        // If you want Entity Framework to drop and regenerate your database
        // automatically whenever you change your model schema, add the following
        // code to the Application_Start method in your Global.asax file.
        // Note: this will destroy and re-create your database with every model change.
        // 
        // System.Data.Entity.Database.SetInitializer(new System.Data.Entity.DropCreateDatabaseIfModelChanges<Persistent.Models.PersistentContext>());

        public DbSet<Domain.Game> Games { get; set; }
        public DbSet<Domain.Player> Players { get; set; }
        public DbSet<Domain.GamePlayer> GamePlayers { get; set; }
       

        public PersistentContext() : base ("DevTask-GB")
        {   
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Domain.GamePlayer>()
                .HasRequired(b => b.Player)
                .WithMany()
                .WillCascadeOnDelete(false);

            base.OnModelCreating(modelBuilder);
        }
        

    }
}